package entry;

import lombok.ToString;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

@ToString
public class Location {
    private String name;
    //坐标位置的实体
    private Map<Integer,Double> location = new HashMap<Integer, Double>();

    public Location(){}

    public Location(Library library,String[] words){
        for (String word:words){
            int index = library.getDataList().indexOf(word.trim());
            Double amount = null;
            if(index != -1){
                amount = location.put(index,1.0);
            }
            if(amount != null){
                location.put(index,amount+1);
            }
        }
    }

    public void put(Integer point,Double count){
        location.put(point,count);
    }

    public int size(){
        return location.size();
    }

    public Iterator<Map.Entry<Integer,Double>> iterator(){
        return location.entrySet().iterator();
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public Map<Integer, Double> getLocation() {
        return location;
    }

    public void remove(Integer integer){
        location.remove(integer);
    }
}
